#!/usr/bin/env bash
set -ex

# Cleanup /tmp
if findmnt /tmp && grep "/tmp " /etc/fstab; then
    umount /tmp
    mount /tmp
else
    rm -rf /tmp/*
fi

# Cleanup /dev/shm
rm -rf /dev/shm/*

# Cleanup caches
sync
echo 3 > /proc/sys/vm/drop_caches
